package ui.swing.spinner;

import java.awt.BorderLayout;

import javax.swing.BoxLayout;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JSpinner;
import javax.swing.SpinnerModel;
import javax.swing.SpinnerNumberModel;
import javax.swing.border.EmptyBorder;

public class SpinnerDemoNumber extends JFrame{

	private static final long serialVersionUID = 8216484001763089496L;

	public SpinnerDemoNumber() {
		super("Spinner Demo (Numbers)");
		
		JPanel p = new JPanel();
		p.setLayout(new BoxLayout(p, BoxLayout.X_AXIS));
		p.setBorder(new EmptyBorder(10, 10, 10, 10));
		
		p.add(new JLabel("Select integer:"));
		SpinnerModel model = new SpinnerNumberModel (
				new Integer(0), //Initial value
				new Integer(0), //Minimum value
				null, //Maximum value - not set
				new Integer(2) // Step
		);
		JSpinner spn = new JSpinner(model);
		p.add(spn);

		getContentPane().add(p, BorderLayout.NORTH);
		setSize(400,75);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setVisible(true);
	}
	
	public static void main(String[] args) {
		new SpinnerDemoNumber();
	}
}
